package com.xiaodou.mjf.application.core.service.impl;

import javax.annotation.Resource;
import javax.transaction.Transactional;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Service;

import com.xiaodou.mjf.application.core.repository.FinancialPackageRepository;
import com.xiaodou.mjf.application.core.service.FinancialPackageService;
import com.xiaodou.mjf.entity.core.FinancialPackage;
import com.xiaodou.mjf.infrastructure.common.app.JpaSimpleService;

/***
 *
 * FinancialPackage业务访问实现
 * 
 * @author XiaoDou.com Code Generator
 * @version 1.0 2014-10-29 17:37:52
 *
 */
@Service
@Transactional
public class FinancialPackageServiceImpl extends
		JpaSimpleService<FinancialPackage, String> implements
		FinancialPackageService {

	Logger logger = LoggerFactory.getLogger(FinancialPackageServiceImpl.class);

	@Resource
	FinancialPackageRepository financialPackageRepository;

	@Override
	protected JpaRepository<FinancialPackage, String> getRepository() {
		return financialPackageRepository;
	}

	public FinancialPackage getRate(Integer term) {
		return financialPackageRepository.getRate(term);

	}

	@Override
	public Page<FinancialPackage> pageAll(FinancialPackage entity) {
		return financialPackageRepository.findAll(preparePage(entity,new Sort(Direction.ASC,"term")));
	}
}
